#!/bin/bash

SERVERS=( "ftp://ftp.fu-berlin.de/pub/misc/movies/database" \
    "ftp://ftp.funet.fi/pub/mirrors/ftp.imdb.com/pub" \
    "ftp://ftp.sunet.se/pub/tv+movies/imdb" )

FILES=($@)

fail=1
srv=0

while [ $fail -eq 1 -a $srv -lt ${#SERVERS[@]} ]; do
    for file in ${FILES[@]}; do
	echo $file
	wget -q "${SERVERS[$srv]}/$file.gz"
	if [ $? -ne 0 ]; then
	    fail=1
	    break
	else
	    fail=0
	fi
    done
    srv=$[srv+1]
done

if [ $fail -eq 1 ]; then
    exit 1
fi

gzip -fd *.list.gz

if [ $? -ne 0 ]; then
    exit 1
fi
